package com.zsp.coupon.vo;


import com.zsp.coupon.constant.CouponCategory;
import com.zsp.coupon.constant.DistributeTarget;
import com.zsp.coupon.constant.ProdcutLine;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class TemplateRequst {
    /**
     * 优惠卷的名称
     */
    private String name;
    //优惠卷logo
    private String logo;
    //优惠卷描述
    private  String desc;
    //优惠卷的分类
    private  String category;
    //产品线
    private  Integer productLine;
    //总数
    private Integer count;
    //创建用户
    private  Long userId;
    //目标用户
    private Integer target;
    //优惠卷规则
    private TemplateRule rule;

    public boolean validate() {
        boolean stringVaild =StringUtils.isNotEmpty(name)
                && StringUtils.isNotEmpty(logo)
                && StringUtils.isNotEmpty(desc);
        boolean  enumvaild =null != CouponCategory.of(category)
                && null != ProdcutLine.of(productLine)
                && null != DistributeTarget.of(target);
        boolean numvaild =count > 0 && userId > 0;

        return stringVaild &&enumvaild &&numvaild &&rule.vaildate();
    }

}
